<?php
// $Id$

/**
 * Controller_Enterprisesetting 控制器
 */
class Controller_Enterprisesetting extends Controller_Abstract
{

    function actionIndex()
    {
        if(null == $this->_app->currentUser())
        {
            return $this->_redirect(url('default/index'));
        }

        $cur_user = $this->_app->currentUserObject();
        if($cur_user->permission_id != 2)
        {
            return $this->_redirect(url('default/index'));
        }


        $ent = Enterprisesetting::find('enterprise_id = ?', $cur_user->enterprise_id)->query();

        if(isset($_POST['audit_open_or_not']))
        {
            $ent->audit_open_or_not =$_POST['audit_open_or_not'];
            $ent->user_history_note_or_not =$_POST['user_history_note_or_not'];
            $ent->enterprise_id = $cur_user->enterprise_id;
            $ent->save();
            return $this->_redirectMessage(
                '提示您:',
                '设置成功',
                url('default/index'));
        }

        $this->_view['ent'] = $ent;
        $this->_viewname = 'index';
    }
}


